<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>

    <title>AdminLTE 3 | 产品列表</title>
    <!-- Tell the browser to be responsive to screen width -->
    <jsp:include page="../include/header.jsp"></jsp:include>
    <!-- Google Font: Source Sans Pro -->
    <%--<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">--%>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Navbar -->
    <jsp:include page="../include/nav.jsp"/>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <jsp:include page="../include/aside.jsp"/>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>订单管理</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">DataTables</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">巡航栏</h3>
                                <button type="button" onclick="toAdd()" class="btn btn-block btn-success btn-sm-2">添加订单</button>
                                <form action="/order/list" method="get" class="form-inline ml-3">
                                    <div class="input-group input-group-sm">
                                        <input value="${myParams.keywords}" name="keywords"
                                               class="form-control form-control-navbar" type="text" placeholder="Search"
                                               aria-label="Search">
                                        <div class="input-group-append">
                                            <button class="btn btn-navbar" type="submit">
                                                <i class="fas fa-search"></i>
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!-- /.card-header -->
                            <div class="card-body">
                                <table id="example2" class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>id</th>
                                        <th>产品名称</th>
                                        <th>订单时间</th>
                                        <th>订单总额</th>
                                        <th>订单状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach var="list" items="${list}">
                                        <tr>
                                            <td>${list.id}</td>
                                            <td>${list.name}</td>
                                            <td><fmt:formatDate value="${list.orderDate}"
                                                                pattern="yyyy年MM月dd日HH点mm分"/></td>

                                            <td>${list.totalMoney}</td>
                                            <td>${list.status==1?"已支付":"未支付"}</td>

                                            <td>
                                                <a href="/order/toEdit/${list.id}">修改</a>
                                                <a href="/order/delete/${list.id}">删除</a>
                                                <a href="/order/editTourist/${list.id}">编辑游客</a>
                                            </td>

                                        </tr>
                                    </c:forEach>

                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <th>id</th>
                                        <th>产品名称</th>
                                        <th>订单时间</th>
                                        <th>订单总额</th>
                                        <th>订单状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </tfoot>
                                </table>
                                <div class="row">
                                <div class="col-sm-12 col-md-7">
                                    <div class="dataTables_paginate paging_simple_numbers" id="example2_paginate">
                                       <c:if test="${myParams.page>=0}">
                                        <ul class="pagination">
                                            <c:if test="${myParams.page!=0}">
                                                <li class="paginate_button page-item previous " id="example2_previous">
                                                    <a href="javascript:jump('${myParams.page-myParams.pageSize}')" aria-controls="example2"
                                                       data-dt-idx="0" tabindex="0"
                                                       class="page-link">上一页</a>
                                                </li>
                                            </c:if>
                                            <c:if test="${myParams.page==0}">
                                                <li class="paginate_button page-item previous disabled" id="example2_previous">
                                                    <a href="javascript:jump('${myParams.page-myParams.pageSize}')" aria-controls="example2"
                                                       data-dt-idx="0" tabindex="0"
                                                       class="page-link">上一页</a>
                                                </li>
                                            </c:if>
                                            <c:forEach begin="0" end="${myParams.totalPage-1}"  varStatus="ind">
                                                <c:if test="${myParams.page eq ind.index}">
                                                    <li class="paginate_button page-item active">
                                                        <a href="#"
                                                           aria-controls="example2"
                                                           data-dt-idx="1"
                                                           tabindex="0"
                                                           class="page-link">${ind.index+1}</a>
                                                    </li>
                                                </c:if>
                                                <c:if test="${myParams.page ne ind.index}">
                                                    <li class="paginate_button page-item ">
                                                        <a href="#"
                                                           aria-controls="example2"
                                                           data-dt-idx="1"
                                                           tabindex="0"
                                                           class="page-link">${ind.index+1}</a>
                                                    </li>
                                                </c:if>
                                            </c:forEach>
                                            <c:if test="${myParams.page eq myParams.totalPage-1}">
                                                <li class="paginate_button page-item next disabled" id="example2_next">
                                                    <a href="javascript:jump('${myParams.page+myParams.pageSize}')" aria-controls="example2" data-dt-idx="7" tabindex="0"
                                                       class="page-link">下一页</a>
                                                </li>
                                            </c:if>
                                            <c:if test="${myParams.page ne myParams.totalPage-1}">
                                                <li class="paginate_button page-item next " id="example2_next">
                                                    <a href="javascript:jump('${myParams.page+myParams.pageSize}')" aria-controls="example2" data-dt-idx="7" tabindex="0"
                                                       class="page-link">下一页</a>
                                                </li>
                                            </c:if>

                                        </ul>
                                       </c:if>
                                    </div>
                                </div>
                                </div>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->


                        <!-- /.card -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->


    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<jsp:include page="../include/footer.jsp"/>
<!-- page script -->
<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../../plugins/daterangepicker/daterangepicker.js"></script>
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- DataTables -->
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<!-- AdminLTE App -->
<script src="../../js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../js/demo.js"></script>

<script>
    $(function () {
        $("#example1").DataTable({
            "responsive": true,
            "autoWidth": false,
        });
        $('#example2').DataTable({
            "paging": false,
            "lengthChange": false,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
    });
    function jump(page) {
        var keywords =$("[name='keywords']").val();
        location.href="/order/list?page="+page+"&keywords="+keywords;
    }
    function toAdd() {
        location.href="/order/toAdd"
    }
</script>
</body>
</html>

